package com.example.store2024.model;

import com.alibaba.fastjson2.JSON;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Getter
@Setter
public class Good {
    private Integer id;//主键
    private String name;//商品名字
    private String summary;
    private String brand;
    private String spec;
    private String pic;//商品图片
    private BigDecimal price;//价格
    private BigDecimal originalPrice;//原价
    private String description;//备注
    private LocalDateTime createTime;//创建时间
    private String detail;
    private String sliderImages;//轮播图json数组

    private Category category;//商品所属类型
    //获取轮播图的图片地址
    public List<String> getStringImagerArray(){

        //JSON转换器格式
        if (this.sliderImages == null){
            return List.of();
        }else {
            return  JSON.parseArray(this.sliderImages,String.class);
        }
    }
}
